home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-11-06 | 2.7 KB | 96 lines | [TEXT/ToyS] |
- --Sample Cyclone script:
- -- 1. converts files dragged on this script from Mac Roman to Unicode 16 bit, turnig off Cyclone alerts, but ordering error log,
- -- 2. sets custom type and creator (BBEdit text),
- -- 3. moves output files to folder "Converted items" which should be created on desktop,
- -- 4. renames output files by cutting a dot added by Cyclone.
-
- --Create "Converted items" folder on desktop before running this script
- --Save this script as an application and drag some text files on it
- --Apple Script 1.3 is required for timed dialog boxes (remove "giving up after 20" if the script is not working for you)
-
- property BBEditSignature : "R*ch"
- property textFileType : "TEXT"
-
- on run
- NoItemsSelected()
- end run
-
- on open theList
- ConvertFilesWithCyclone(theList)
- end open
-
-
- on ConvertFilesWithCyclone(theList)
-
- tell application "Cyclone"
- activate
-
- set option NoAlertDoLog
-
- try
- convert theList from Mac_Roman_Euro_Sign to Unicode_2_1_Standard
- on error
- display dialog "An error occured during conversion." buttons {"Stop"} default button 1 ¬
- giving up after 20
- end try
- set outList to result
-
- set option DoAlertNoLog
-
- quit
- end tell
-
- tell application "Finder"
-
- --repeat with y in theList
- -- delete y --move original to the trash
- --end repeat
-
- repeat with curr_file in outList
- --we must check if the output item exists
- --Cyclone returns invalid file spec if conversion fails
- if exists curr_file then
- --set the sample type and creator
- set creator type of curr_file to BBEditSignature
- set file type of curr_file to textFileType
-
- --move file to sample folder "Converted items" on the desktop
- set the moved_file to move curr_file to folder "Converted items" of desktop with replacing
-
- --cut the last char of filename which is a bullet
- set the current_name to name of moved_file
- set the new_name to (characters 1 thru -2 of the current_name) as string
- my rename_file(moved_file, the new_name)
- end if
- end repeat
-
-
- end tell
-
- end ConvertFilesWithCyclone
-
- on NoItemsSelected()
- display dialog "No file selected." & return & ¬
- "Drag a text file onto this script." buttons {"OK"} default button 1 ¬
- giving up after 20
- end NoItemsSelected
-
- -- file renaming with replacing
- on rename_file(this_file, new_file_name)
- tell application "Finder"
- activate
-
- set the parent_container_path to (the container of this_file) as text
- set the new_file to (the parent_container_path & new_file_name)
- if (exists file new_file) then
- delete file new_file
- end if
-
- try
- set the name of this_file to new_file_name
- on error
- display dialog "Error renaming file" buttons {"OK"} default button 1 ¬
- giving up after 20
- end try
- end tell
- end rename_file